<?php
use common\components\widgets\Datetimepicker;
use common\components\helpers\Fun;
use common\components\extenders\MenuManage;
use doumiaoduo\layer\LayerConfirmWidget;
use doumiaoduo\layer\LayerIframeWidget;

LayerConfirmWidget::widget();
LayerIframeWidget::widget();
use yii\helpers\Html;
Datetimepicker::widget(['flag'=>'timepicker','format'=>'Y-m-d']);
Datetimepicker::widget(['timepicker' => 'true','datepicker'=>'false','format'=>'H:i','step'=>'5']);
?>
<div class="yx-praise-list-box yx-praise-box yx-radius2">
    <div id="search-area" class="yx-bgf7f7f7 yx-radius5 zx-mg yx-function2 yx-pr0">
            <?= Html::beginForm(Fun::url(['newclassmanage/index']), 'get', ['enctype' => 'multipart/form-data']) ?>
            <?= \common\components\helpers\Search::textInput('teacher', \Yii::$app->request->get('teacher'), ['label'=>'教师姓名','class' => 'yx-width150 zx-lh24 yx-ml6']); ?>
            <?= \common\components\helpers\Search::textInput('course', \Yii::$app->request->get('course'), ['label'=>'课程名称','class' => 'yx-width150 zx-lh24 yx-ml6']); ?>
            <?= \common\components\helpers\Search::textInput('classroom', \Yii::$app->request->get('classroom'), ['label'=>'教室名称','class' => 'yx-input-text zx-width150 yx-ml6']); ?>
            <?= \common\components\helpers\Search::textInput('mechanic', \Yii::$app->request->get('mechanic'), ['label'=>'机构','class' => 'yx-input-text zx-width150 yx-ml6']); ?>
        
            <?= \common\components\helpers\Search::dropDownList('status', \Yii::$app->request->get('status'), [null=>'请选择',0=>'未开班',1=>'已开班',2=>'已结课'],['label'=>'状态','class' => 'diy_select_txt','promote'=>'请选择']); ?>
            <?= \common\components\helpers\Search::dropDownList('cate', \Yii::$app->request->get('cate'), $cate,['label'=>'课程分类','class' => 'diy_select_txt','promote'=>'请选择']); ?>
            <?= \common\components\helpers\Search::textInput('opentime', \Yii::$app->request->get('opentime'), ['label'=>'开班时间','class' => 'timepicker yx-input-text zx-width150 yx-ml6']); ?>
            <?= \common\components\helpers\Search::textInput('class_date', \Yii::$app->request->get('class_date'), ['label'=>'上课时间','class' => 'search timepicker yx-width150 zx-lh24 yx-ml6']); ?>
            <?= \common\components\helpers\Search::submitButton('搜索', ['id'=>'search-handle','class'=>"yx-search yx-radius2"]); ?>
            <?php Html::endForm() ?>
        </div>
        <div class="docs-main zx-mg">
            <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check" data-shelve_url="<?=Fun::url('newclassmanage/generatedgoods')?>"  data-tablesaw-mode="swipe" data-tablesaw-minimap >
                <thead>
                <tr class="yx-bgd2f6ec">
                    <th>课程名称</th>
                    <th>机构名称</th>
                    <th>上课老师</th>
                    <th>教室名</th>
                    <th>开班人数</th>
                    <th>报名人数</th>
                    <th>最大人数</th>
                    <th>上课时间</th>
                    <th>开班时间</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
            <?php if($data != null) { ?>
                  <?php foreach ($data as $item) { ?>
                    <tr>
                        <td><?=$item['course_name']?></td>
                        <td><?=$item['mechanic_name']?></td>
                        <td><?=$item['teacher_name']?></td>
                        <td><?=$item['classroom_name']?></td>
                        <td><?=$item['opening_number']?></td>
                        <td><?=$item['student_count']?></td>
                        <td><?=$item['max_number']?></td>
                        <td><?=$item['class_time']?></td>
                        <td><?=$item['start_day']?></td>
                        <td><?=$item['status_name']?></td>
                        <td><?=$item['newoperate']?></td>
                    </tr>
                  <?php } ?>
            <?php } ?>
            </table>
            <div style="text-align: right"><?= common\components\widgets\GoPager::widget(['pagination' => $pages]) ?></div>
        </div>
</div>
<?php
$js = <<<JS
   layer.config({
        extend: ['skin/customskin/style.css']//加载您的扩展样式
    });
   $(document).on('click','.shelve',function(){
       var _this = $(this);
       var class_id = _this.data('id');
       _this.attr("disabled",true);
       $.ajax({
           url : $('#tablesaw').data('shelve_url'),
           type:'get',
           dataType: 'json',
           data:{class_id:class_id},
           beforeSend:function(){
              var index = layer.load(0, { shade: [0.5, '#393D49'] });
            },
           complete:function(){
              layer.close(layer.load(0, { shade: [0.5, '#393D49'] }));  
            },
           success:function(data) {
             if(data.status == 1){
                  layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                     location.reload();
                  }else {
                      layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
                     location.reload();
                  }
           }   
       });
   });
JS;
$this->registerJS($js);
?>